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HYk
iP7/IuHy64LuN2u+irB7tohKteBZWUsThX0tfWUCgYEA/LguWJ3wXx2yrDRVQCi8
YVu2bfuHjV8yZiDe4dv9WTeAUskf6P5eDpwHMiZo38yCidk9ImPCS++33D7Fx4Jl
sDjsIoIM5Jjndf85Bw5BvyqsilH7krQsPXYxh0kHh+TgzEcBqVf5xCPJTaBx6RvM
z7mCFJ5aukNX9ER04rhJUmECgYBCgsyQDWDh7uLMfQ1cflVecTRkd9NXC2UcQp4F
zEi/w1Be95JQQc0zXB9IaDoL4SRqbS2vQ3Ztt2OHUqtWQEzHlq9TMbmm+j5ZDm3N
IgDfzjM75r+Qzk2FSVt7XhVCXi7YDm5DYtJYaQjxAwlg/WfU4Hbg2nRQxmG407VK
gyx16QKBgQCMyC2Qxowquemoy20zRciR/MLeTNLGawEogDhvRqM1iIscPDC3P8WO
mxzMmiflBbEfWqZqcq/bjKI0u5SWkX9RDoTCSOR1c4Behg0thJXspEM/48h3WtpW
Vqmwbpc2v12RDK33/UqVH9ft5KaanZE2MSnrgk8Ufac35N0DtyXSCQ==
-----END RSA PRIVATE KEY-----"""

file_obj = StringIO(key_str)
print(file_obj)
private_key = paramiko.RSAKey(file_obj)
transport = paramiko.Transport(('192.168.7.32', 22))
transport.connect(username='yx', pkey=private_key)

ssh = paramiko.SSHClient()
ssh._transport = transport

stdin, stdout, stderr = ssh.exec_command('df')
result = stdout.read()

transport.close()

print(result.decode())
